package com.tansty.web.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tansty.common.utils.CommonUtil;
import com.tansty.pojo.po.UserMessages;
import com.tansty.pojo.vo.ResultVO;
import com.tansty.service.service.UserMessagesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * description:  <br>
 * date: 2021/9/4 14:18 <br>
 * author: ztz <br>
 * version: 1.0 <br>
 */
@RestController
@RequestMapping("/messages")
public class UserMessagesController {
    @Autowired
    UserMessagesService userMessagesService;
    @GetMapping("/one/{userName}")
    public ResultVO getOne(@PathVariable String userName){
        return CommonUtil.ajaxReturn(userMessagesService.getOne(userName));
    }
    @PutMapping("/update")
    public ResultVO updateOne(@RequestBody UserMessages userMessages){
        boolean result = userMessagesService.update(userMessages,
                new QueryWrapper<UserMessages>().eq("user_id", userMessages.getUserId())
        );
        return CommonUtil.ajaxReturn(result);
    }
}
